package cn.hill4j.tool.spring.ext.alias;

import java.util.Objects;

/**
 * @author hillchen
 * ClassName: BeanAliasInfo
 * Description: BeanAliasInfo springbean 别名定义信息
 * Date 2023年08月08日
 * @version: 1.0
 */
public class BeanAliasInfo {
    /**
     * springbean 别名
     */
    private final String alias;
    /**
     * springbean 别名分组
     */
    private final String group;

    public BeanAliasInfo(String alias, String group) {
        this.alias = alias;
        this.group = group;
    }

    public BeanAliasInfo(String alias) {
        this(alias, BeansAliasUtils.DEF_GROUP_NAME);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BeanAliasInfo that = (BeanAliasInfo) o;
        return alias.equals(that.alias) && group.equals(that.group);
    }

    @Override
    public int hashCode() {
        return Objects.hash(alias, group);
    }
    /**
     * @author hillchen
     * Description: 构建springbean 别名
     * Date 2023/8/8 23:16
     * @return String
     **/
    public String createBeanAliasName(){
        return BeansAliasUtils.createAliasBeanName(group,alias);
    }
}
